/**
 * @author xsg
 * @author zh
 * @author zyh
 */

function  GlobalVar(){
    this.floorNumber    = 0;
    this.floorName      = "";
    this.underground    = true;
    this.left           = true;
};


//parseXX函数对应文件中一个geometry
//函数名称带O表示优化

function parseMultiPoint(geometry)
{
    var geometryArray = new Array();
    for (var i_coords in geometry.coordinates) {
        geometryArray.push(geometry.coordinates[i_coords][0]) ;
        geometryArray.push(geometry.coordinates[i_coords][1]) ;
        geometryArray.push(geometry.coordinates[i_coords][2]) ;
    }

    return geometryArray;
}
function parseMultiLineString(geometry)
{
    var geometryArray = new Array();
    for (var i_coords in geometry.coordinates) {
        var lsArray = new Array();
        for(var i in geometry.coordinates[i_coords])
        {
            lsArray.push(geometry.coordinates[i_coords][i][0]) ;
            lsArray.push(geometry.coordinates[i_coords][i][1]) ;
            lsArray.push(geometry.coordinates[i_coords][i][2]) ;
        }
        geometryArray.push(lsArray);
    }

    return geometryArray;
}
function parseMultiLineStringO(geometry)
{//根据文件数据情况，将四个linestring合并成一个
    var geometryArray = new Array();
    var lsArray;
    for (var i_coords in geometry.coordinates) {
        if(i_coords%4 == 0)
            lsArray = new Array();
        lsArray.push(geometry.coordinates[i_coords][0][0]) ;
        lsArray.push(geometry.coordinates[i_coords][0][1]) ;
        lsArray.push(geometry.coordinates[i_coords][0][2]) ;
        if(i_coords%4 == 3)
            geometryArray.push(lsArray);
    }

    return geometryArray;
}
function parseMultiPolygon(geometry, json_name)
{
    var geometryArray = new Array();
    for (var i_coords in geometry.coordinates) {
        var coordinate = geometry.coordinates[i_coords][0];//不考虑有洞的情况，多读深一层
        var polygonArray = new Array();

        if(coordinate.length < 4)//部分文件存在仅三个顶点数据且第一个和第三个还重复的情况，不可用，故剔除
            console.log(json_name + " error!");
        else {
            for (var i in coordinate) {
                //console.log("features geometry coordinate:" + coordinate[i]); //输出一维数组：+ 字符串导致改变输出形式
                //polygonArray.push(new THREE.Vector3(coordinate[i][0], coordinate[i][1],coordinate[i][2])) ;
                //polygonArray.push(new THREE.Vector3(coordinate[i][0]*scaleBim, coordinate[i][1]*scaleBim, coordinate[i][2])) ;
                if(i < coordinate.length-1)//剔除最后一个重复的数据
                {
                    polygonArray.push(coordinate[i][0]) ;
                    polygonArray.push(coordinate[i][1]) ;
                    polygonArray.push(coordinate[i][2]) ;
                }
            }
            geometryArray.push(polygonArray);
        }
    }

    return geometryArray;
}